{extend name="ace/layout/default" /}

{block name="title"}配置管理{/block}

{block name="content"}
<h3 class="header smaller lighter blue">
    配置列表
    <small>
        <i class="icon-double-angle-right"></i>
        Configs list
    </small>
</h3>
<div class="row">
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <a href="{:url('detail') }">
            <button class="btn btn-sm btn-success">
                <i class="icon-zoom-in bigger-120"></i>
                添加配置
            </button>
        </a>
        <a href="javascript:;" onclick="batchDelOperation('{:url(\'delete\')}');">
            <button type="button" class="btn btn-sm btn-danger">
                <i class="icon-trash bigger-120"></i>
                批量删除
            </button>
        </a>
        <a href="javascript:;" onclick="batchExport('{:url(\'export\')}');">
            <button class="btn btn-sm btn-info">
                <i class="icon icon-cloud-download bigger-120"></i>
                导出
            </button>
        </a>
        <a href="javascript:;" onclick="pushRefreshConfig('{:url(\'pushRefreshConfig\')}')">
            <button class="btn btn-sm btn-warning">
                <span class="icon-refresh bigger-110"></span>
                同步配置文件
            </button>
        </a>
    </div>
    <div class="col-xs-12 col-sm-12 col-ml-12">
        <div class="space-4"></div>
        <form action="" method="get" id="form_data" class="first_form float-left">
            <?php $config_group = input('config_group', -1);?>
            <select name="config_group">
                <option value="-1" {if $config_group == -1}selected{/if}> 请选择配置分组 </option>
                {if !empty($config_group_list)}
                    {foreach $config_group_list as $key => $value}
                        <option value="{$key}" {if $config_group == $key}selected{/if}> {$value} </option>
                    {/foreach}
                {/if}
            </select>
            <?php $config_type = input('config_type', -1);?>
            <select name="config_type">
                <option value="-1" {if $config_type == -1}selected{/if}> 请选择配置类型 </option>
                {if !empty($config_type_list)}
                    {foreach $config_type_list as $key => $value}
                    <option value="{$key}" {if $config_type == $key}selected{/if}> {$value} </option>
                    {/foreach}
                {/if}
            </select>
            <?php $is_check = input('is_check', -1); ?>
            <select name="is_check">
                <option value="-1" {if $is_check == -1}selected{/if}> 请选择状态 </option>
                <option value="1" {if $is_check == 1}selected{/if}> 正常 </option>
                <option value="0" {if $is_check == 0}selected{/if}> 禁用 </option>
            </select>
            <span class="input-icon">
                <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input"
                       autocomplete="off" name="search" value="{:input('search', '')}"/>

                <button type="button" class="btn btn-purple btn-sm" onclick="$('form.first_form').submit();">
                    Search
                    <i class="icon-search icon-on-right bigger-110"></i>
                </button>
            </span>
        </form>
    </div>
</div>
<div class="space-4"></div>
<div class="table-header">Configs list</div>
<div class="table-responsive">
    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th class="center">
                <label>
                    <input type="checkbox" class="ace" name="config_id[]" />
                    <span class="lbl"></span>
                </label>
            </th>
            <th class="text-center"> Id </th>
            <th class="text-center"> 配置标题 </th>
            <th class="text-center"> 配置名称 </th>
            <th class="text-center hidden-sm"> 配置值 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 配置备注 </th>
            <th class="text-center hidden-sm"> 配置分组 </th>
            <th class="text-center hidden-sm"> 配置类型 </th>
            <th class="text-center hidden-sm"> 排序 </th>
            <th class="text-center hidden-sm hidden-xs hidden-md"> 创建时间 </th>
            <th class="text-center"> 状态 </th>
            <th class="text-center"> 操作 </th>
        </tr>
        </thead>
        <tbody>
            {if !empty($list) && $list->total()}
                {foreach $list as $key => $item}
                    <tr id="id_{$item->config_id}" name="{$item->config_title}">
                        <td class="text-center">
                            <label>
                                <input type="checkbox" class="ace" name="config_id[]" value="{$item->config_id}" />
                                <span class="lbl"></span>
                            </label>
                        </td>
                        <td class="text-center"> <a href="javascript:;">{$item->config_id}</a> </td>
                        <td class="text-center"> {$item->config_title} </td>
                        <td class="text-center"> {$item->config_name} </td>
                        <td class="text-center hidden-sm">
                            {$item->config_value|htmlspecialchars_decode|cut_str=30}
                        </td>
                        <td class="text-center hidden-sm hidden-xs hidden-md"> {$item->config_remarks|cut_str=20} </td>
                        <td class="text-center hidden-sm"> {$config_group_list[$item->config_group] ?? $item->config_group} </td>
                        <td class="text-center hidden-sm"> {$config_type_list[$item->config_type] ?? $item->config_type} </td>
                        <td class="text-center hidden-sm"> {$item->config_sort} </td>
                        <td class="text-center hidden-sm hidden-xs hidden-md">
                            {:date('Y-m-d H:i', $item->created_time)}
                        </td>
                        <td class="text-center">
                            {switch $item->is_check|intval }
                            {case 1}
                                <span class="label label-success"> 正常 </span>
                            {/case}
                            {default /}
                                <span class="label label-danger"> 禁用 </span>
                            {/switch}
                        </td>
                        <td class="text-center">
                            <div class="hidden-sm hidden-xs action-buttons">
                                {switch $item->is_check|intval }
                                {case 1}
                                    <a class="btn btn-xs btn-danger" title="禁用“{$item->config_title}”配置" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'config_id' : '{$item->config_id}', 'change_field' : 'is_check', 'change_value':0})">
                                        <i class="icon-lock bigger-120"></i> 禁用
                                    </a>
                                {/case}
                                {default /}
                                    <a class="btn btn-xs btn-success" title="启用“{$item->config_title}”配置" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'config_id' : '{$item->config_id}', 'change_field' : 'is_check', 'change_value':1})">
                                        <i class="icon-unlock bigger-120"></i> 启用
                                    </a>
                                {/switch}

                                <a class="btn btn-xs btn-info" title="编辑“{$item->config_title}”配置" href="{:url('detail', ['config_id' => $item->config_id])}">
                                    <i class="icon-edit bigger-120"></i> 编辑
                                </a>
                                <a class="btn btn-xs btn-danger" title="删除“{$item->config_title}”配置" onclick="delOperation({$item->config_id}, '{:url(\'delete\')}')">
                                    <i class="icon-trash bigger-120"></i> 删除
                                </a>
                            </div>
                            <div class="hidden-md hidden-lg">
                                <div class="inline position-relative">
                                    <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                        <i class="icon-cog bigger-110"></i>
                                    </button>
                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                        {switch $item->is_check|intval }
                                        {case 1}
                                        <li>
                                            <a class="btn btn-xs btn-danger" title="禁用“{$item->config_title}”配置" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'config_id' : '{$item->config_id}', 'change_field' : 'is_check', 'change_value':0})">
                                                <i class="icon-lock bigger-120"></i> 禁用
                                            </a>
                                            <div class="hr hr-dotted"></div>
                                        </li>
                                        {/case}
                                        {default /}
                                        <li>
                                            <a class="btn btn-xs btn-success" title="启用“{$item->config_title}”配置" href="javascript:;" onclick="changeFiledStatus(this, '{:url(\'changeFiledStatus\')}', {'config_id' : '{$item->config_id}', 'change_field' : 'is_check', 'change_value':1})">
                                                <i class="icon-unlock bigger-120"></i> 启用
                                            </a>
                                            <div class="hr hr-dotted"></div>
                                        </li>
                                        {/switch}
                                        <li>
                                            <a class="btn btn-xs btn-info" title="编辑“{$item->config_title}”配置" href="{:url('detail', ['config_id' => $item->config_id])}">
                                                <i class="icon-edit bigger-120"></i> 编辑
                                            </a>
                                        </li>
                                        <li>
                                            <div class="hr hr-dotted"></div>
                                            <a class="btn btn-xs btn-danger" title="删除“{$item->config_title}”配置" onclick="delOperation({$item->config_id}, '{:url(\'delete\')}')">
                                                <i class="icon-trash bigger-120"></i> 删除
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </td>
                    </tr>
                {/foreach}
            {else/}
                <tr class="text-center">
                    <td colspan="100"> 暂无数据！ </td>
                </tr>
            {/if}
        </tbody>
    </table>

    <div class="hr hr-18 dotted hr-double"></div>

    {if !empty($list) && $list->total()}
        <div id="pageList" class="float-right">
            {$list|raw}
        </div>
    {/if}
</div><!-- /.table-responsive -->
{/block}